<template>
    <div id="app">
        <!-- 顶部导航 -->
        <div class="header">
            <div class="container top-nav">
                <div class="logo" @click="goToHome">易买网</div>
                <div>资讯详情</div>
            </div>
        </div>
        
        <div class="container">
            <!-- 内容区域 -->
            <div class="content">
                <!-- 主内容 -->
                <div class="main-content">
                    <div v-if="loading" class="loading">正在加载新闻内容...</div>
                    <div v-else class="news-detail">
                        <h1 class="news-title">{{ title }}</h1>
                        <div class="news-meta">
                            <span>发布时间：{{ createTime || '2023-10-15' }}</span>
                        <div class="news-content">
                            <p>{{ content }}</p>
                        </div>
                    </div>
                    
                    <button class="back-btn" @click="goToHome">返回首页</button>
                </div>
            </div>
        </div>
        
        <div class="footer">
            <div class="container">
                <p>© 2023 易买网 版权所有</p>
            </div>
        </div>
    </div>
    </div>
</template>

<script setup>
import { useRoute } from 'vue-router'
import { ref,onMounted, onUnmounted  } from 'vue'
import store from '@/store'

const route = useRoute()

const title = ref(route.query.title) 
const content = ref(route.query.content) 
const createTime =ref(route.query.createTime)

function goToHome(){
    history.back()
}


// 进入管理页面时隐藏HeaderView
onMounted(() => {
    store.commit('setShowPage', 1)
})

// 离开管理页面时恢复HeaderView
onUnmounted(() => {
    store.commit('setShowPage', 0)
})

</script>


 <style scoped>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: "Microsoft YaHei", sans-serif;
        }
        
        body {
            background-color: #f5f5f5;
            color: #333;
        }
        
        .container {
            width: 1200px;
            margin: 0 auto;
        }
        
        /* 顶部导航 */
        .header {
            background-color: #e43130;
            color: white;
            padding: 10px 0;
        }
        
        .top-nav {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .logo {
            font-size: 28px;
            font-weight: bold;
            cursor: pointer;
        }
        
        /* 内容区域 */
        .content {
            display: flex;
            margin-top: 20px;
        }
        
        .main-content {
            flex: 1;
            background: white;
            padding: 25px;
            border-radius: 6px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            min-height: 500px;
        }
        
        .news-detail {
            margin-bottom: 30px;
        }
        
        .news-title {
            font-size: 24px;
            color: #e43130;
            margin-bottom: 15px;
            padding-bottom: 10px;
            border-bottom: 2px solid #f0f0f0;
            text-align: center;
        }
        
        .news-meta {
            text-align: center;
            color: #999;
            margin-bottom: 20px;
            font-size: 14px;
        }
        
        .news-content {
            line-height: 1.8;
            font-size: 16px;
            color: #555;
        }
        
        .news-content p {
            margin-bottom: 15px;
            text-indent: 2em;
        }
        
        .back-btn {
            background-color: #e43130;
            color: white;
            padding: 12px 25px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            display: block;
            margin: 30px auto;
            transition: background-color 0.3s;
        }
        
        .back-btn:hover {
            background-color: #c62a29;
        }
        
        .loading {
            text-align: center;
            padding: 40px;
            color: #999;
        }
        
        /* 页脚 */
        .footer {
            text-align: center;
            padding: 20px 0;
            color: #999;
            font-size: 14px;
            margin-top: 30px;
            border-top: 1px solid #eee;
        }
        
        /* 响应式设计 */
        @media (max-width: 1200px) {
            .container {
                width: 95%;
            }
        }
        
        @media (max-width: 768px) {
            .news-title {
                font-size: 20px;
            }
            
            .news-content {
                font-size: 15px;
            }
            
            .back-btn {
                padding: 10px 20px;
                font-size: 15px;
            }
        }
    </style>